<div class="bs-sidebar hidden-print affix well" role="complementary">

	{% for menu in nav %}
		{% if menu.children %}
			{%- for nav_item in menu.children %}
				{% if nav_item.active %}
					<div class="code-title">{{ nav_item.title }}</div>
				{% endif %}
			{%- endfor %}
		{% endif %}
	{% endfor %}


	<ul class="nav bs-sidenav">
		{% for nav_item in nav %}
			{% if nav_item.active %}
				{% if nav_item.children %}
					{% for nav_item2 in nav_item.children %}
						{% if nav_item2.active %}
							{% if nav_item2.children %}
								{% for nav_item3 in nav_item2.children %}
									<li class="{% if nav_item3.active %}active{% endif %}">
										<a class="itm-l1" href="{{ nav_item3.url }}">{{ nav_item3.title }}</a>
										{% if nav_item3 == page %}
										<ul class="nav">
											{% for toc_item in page.toc %}
											<li class="{% if toc_item.active %}active {% endif %}"><a href="{{ toc_item.url }}">{{ toc_item.title }}</a>
												{% for toc_item in toc_item.children %}
												<ul class="nav nav-l2">
													<li><a class="itm-l2" href="{{ toc_item.url }}">{{ toc_item.title }}</a></li>
												</ul>
												{% endfor %}
											</li>
												{% endfor %}
										</ul>
										{% endif %}
									</li>
								{% endfor %}
							{% else %}
								{% if nav_item2 == page %}
									{% for toc_item in page.toc %}
										<li class="{% if toc_item.active %}active {% endif %}"><a href="{{ toc_item.url }}">{{ toc_item.title }}</a>
											{% for toc_item in toc_item.children %}
											<ul class="nav nav-l2">
												<li><a class="itm-l2" href="{{ toc_item.url }}">{{ toc_item.title }}</a></li>
											</ul>
											{% endfor %}
										</li>
									{% endfor %}
								{% endif %}
							{% endif %}
						{% endif %}
					{% endfor %}
				{% endif %}
			{% endif %}
		{% endfor %}
	</ul>
</div>